package com.neuedu.dao.impl;

import java.util.List;
import java.util.Map;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.neuedu.dao.GoodsDao;
import com.neuedu.dao.GoodsTypeDao;
import com.neuedu.model.Goods;
import com.neuedu.model.GoodsType;

//把dao接口实现类，交给spring进行管理
@Repository
public class GoodsTypeDaoImpl implements GoodsTypeDao {

	//代码层级的整合spring+mybatis
	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;			
	public void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) {
				this.sqlSessionTemplate = sqlSessionTemplate;
			}

	@Override
	public int countGoodsType() {
		return sqlSessionTemplate.getMapper(GoodsTypeDao.class).countGoodsType();
	}

	@Override
	public List<GoodsType> findAll(Map<String, Object> map) {
		return sqlSessionTemplate.getMapper(GoodsTypeDao.class).findAll(map);
	}

	@Override
	public int addGoodsType(GoodsType g) {
		return sqlSessionTemplate.getMapper(GoodsTypeDao.class).addGoodsType(g);
	}

	@Override
	public int updateGoodsType(GoodsType g) {
		return sqlSessionTemplate.getMapper(GoodsTypeDao.class).updateGoodsType(g);
	}

	@Override
	public int deleteGoodsType(int id) {
		return sqlSessionTemplate.getMapper(GoodsTypeDao.class).deleteGoodsType(id);
	}

}
